package admin

import (
	"geekai/core"
	"go.uber.org/fx"
)

// RegisterAdminHandlerObj 注册后台管理接口
func RegisterAdminHandlerObj() fx.Option {
	return fx.Module("admin",
		fx.Provide(NewAdminHandler),
		fx.Provide(NewDashboardHandler),
		fx.Provide(NewUserHandler),
		fx.Provide(NewUploadHandler),
		fx.Provide(NewApiKeyHandler),
		fx.Provide(NewChatModelHandler),
		fx.Provide(NewChatAppTypeHandler),
		fx.Provide(NewChatAppHandler),
		fx.Provide(NewProductHandler),
		fx.Provide(NewOrderHandler),
		fx.Provide(NewRedeemHandler),
		fx.Provide(NewFunctionHandler),
		fx.Provide(NewChatHandler),
		fx.Provide(NewImageHandler),
		fx.Provide(NewMediaHandler),
		fx.Provide(NewConfigHandler),
		fx.Provide(NewMenuHandler),
		fx.Provide(NewPowerLogHandler),
		fx.Provide(NewPromptHandler),
		fx.Invoke(func(s *core.AppServer, h *ManagerHandler) {
			group := s.Engine.Group("/api/admin/")
			group.POST("login", h.Login)
			group.GET("logout", h.Logout)
			group.POST("save", h.Save)
			group.GET("session", h.Session)
			group.GET("list", h.List)
			group.GET("remove", h.Remove)
			group.POST("enable", h.Enable)
			group.POST("resetPass", h.ResetPass)
		}),
		fx.Invoke(func(s *core.AppServer, h *DashboardHandler) {
			group := s.Engine.Group("/api/admin/dashboard/")
			group.GET("stats", h.Stats)
		}),
		fx.Invoke(func(s *core.AppServer, h *UserHandler) {
			group := s.Engine.Group("/api/admin/user/")
			group.POST("saveOrUpdate", h.SaveOrUpdate)
			group.GET("list", h.List)
			group.GET("loginLog", h.LoginLog)
			group.POST("resetPass", h.ResetPass)
			group.GET("remove", h.Remove)
		}),
		fx.Invoke(func(s *core.AppServer, h *UploadHandler) {
			group := s.Engine.Group("/api/admin/file/")
			group.POST("upload", h.Upload)
			group.POST("list", h.List)
		}),
		fx.Invoke(func(s *core.AppServer, h *ApiKeyHandler) {
			group := s.Engine.Group("/api/admin/apikey/")
			group.POST("saveOrUpdate", h.SaveOrUpdate)
			group.POST("set", h.Set)
			group.GET("list", h.List)
			group.GET("remove", h.Remove)
		}),
		fx.Invoke(func(s *core.AppServer, h *ChatModelHandler) {
			group := s.Engine.Group("/api/admin/model/")
			group.POST("saveOrUpdate", h.SaveOrUpdate)
			group.GET("list", h.List)
			group.POST("sort", h.Sort)
			group.POST("set", h.Set)
			group.GET("remove", h.Remove)
		}),
		fx.Invoke(func(s *core.AppServer, h *ChatAppTypeHandler) {
			group := s.Engine.Group("/api/admin/app/type/")
			group.POST("saveOrUpdate", h.SaveOrUpdate)
			group.GET("list", h.List)
			group.GET("remove", h.Remove)
			group.POST("enable", h.Enable)
			group.POST("sort", h.Sort)
		}),
		fx.Invoke(func(s *core.AppServer, h *ChatAppHandler) {
			group := s.Engine.Group("/api/admin/role/")
			group.POST("saveOrUpdate", h.SaveOrUpdate)
			group.GET("list", h.List)
			group.POST("sort", h.Sort)
			group.POST("set", h.Set)
			group.GET("remove", h.Remove)
		}),
		fx.Invoke(func(s *core.AppServer, h *ProductHandler) {
			group := s.Engine.Group("/api/admin/product/")
			group.POST("saveOrUpdate", h.SaveOrUpdate)
			group.GET("list", h.List)
			group.POST("sort", h.Sort)
			group.POST("enabled", h.Enabled)
			group.GET("remove", h.Remove)
		}),
		fx.Invoke(func(s *core.AppServer, h *OrderHandler) {
			group := s.Engine.Group("/api/admin/order/")
			group.POST("list", h.List)
			group.GET("remove", h.Remove)
			group.GET("clear", h.Clear)
		}),
		fx.Invoke(func(s *core.AppServer, h *RedeemHandler) {
			group := s.Engine.Group("/api/admin/redeem/")
			group.POST("create", h.Create)
			group.POST("set", h.Set)
			group.POST("export", h.Export)
			group.GET("list", h.List)
			group.GET("remove", h.Remove)
		}),
		fx.Invoke(func(s *core.AppServer, h *FunctionHandler) {
			group := s.Engine.Group("/api/admin/function/")
			group.POST("save", h.Save)
			group.POST("set", h.Set)
			group.GET("list", h.List)
			group.GET("remove", h.Remove)
			group.GET("token", h.GenToken)
		}),
		fx.Invoke(func(s *core.AppServer, h *ChatHandler) {
			group := s.Engine.Group("/api/admin/chat/")
			group.POST("chatList", h.ChatList)
			group.POST("messagesList", h.MessagesList)
			group.GET("history", h.History)
			group.GET("removeChat", h.RemoveChat)
			group.GET("removeMessage", h.RemoveMessage)
		}),
		fx.Invoke(func(s *core.AppServer, h *ImageHandler) {
			group := s.Engine.Group("/api/admin/image/")
			group.POST("list/mj", h.MjList)
			group.POST("list/sd", h.SdList)
			group.POST("list/dall", h.DallList)
			group.GET("remove", h.Remove)
		}),
		fx.Invoke(func(s *core.AppServer, h *MediaHandler) {
			group := s.Engine.Group("/api/admin/media/")
			group.POST("list/suno", h.SunoList)
			group.POST("list/luma", h.LumaList)
			group.GET("remove", h.Remove)
		}),
		fx.Invoke(func(s *core.AppServer, h *ConfigHandler) {
			group := s.Engine.Group("/api/admin/config/")
			group.POST("update", h.Update)
			group.GET("get", h.Get)
		}),
		fx.Invoke(func(s *core.AppServer, h *MenuHandler) {
			group := s.Engine.Group("/api/admin/menu/")
			group.POST("saveOrUpdate", h.SaveOrUpdate)
			group.POST("enable", h.Enable)
			group.POST("sort", h.Sort)
			group.GET("list", h.List)
			group.GET("remove", h.Remove)
		}),
		fx.Invoke(func(s *core.AppServer, h *PowerLogHandler) {
			group := s.Engine.Group("/api/admin/powerLog/")
			group.POST("list", h.List)
		}),
		fx.Invoke(func(s *core.AppServer, h *PromptHandler) {
			group := s.Engine.Group("/api/admin/prompt/")
			group.POST("meta", h.MetaPrompt)
		}),
	)
}
